package com.soft.admin.web;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.soft.admin.dto.CentreDTO;
import com.soft.admin.service.CentreService;
import com.soft.support.PageParam;

@Controller
@RequestMapping(value = "/admin/centre.do")
public class CentreController extends BaseController {
	private CentreService centreService;
	
	@RequestMapping(params = "index")
	public String get(HttpServletResponse response, HttpServletRequest request, CentreDTO params, 
			PageParam page) throws IOException {
		String res = this.centreService.get(params, page);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "indextochannel")
	public String getChannel(HttpServletResponse response, HttpServletRequest request) 
			throws IOException {
		String res = this.centreService.getChannel();
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "edit")
	public String edit(HttpServletResponse response, HttpServletRequest request, CentreDTO params) 
			throws IOException {
		String res = this.centreService.addOrEdit(params);
		response.getWriter().print(res);
		return null;
	}

	@Autowired
	public void setCentreService(CentreService centreService) {
		this.centreService = centreService;
	}
	
	
}
